<!DOCTYPE html><html><head><meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" />
<title>KVS</title>
<link rel="stylesheet" href="https://n2o.dev/blank.css" />
<link rel="stylesheet" href="https://n2o.dev/zima.css" />
</head><body><nav>
    <a href="https://n2o.dev">DEV</a>
    <a href="https://kvs.n2o.dev">KVS</a>
    <a href="#" style="background:#ededed;">API</a>
  <div class="dropdown">
    <a onclick="drop()" class="dropbtn">EN</a>
    <div id="dropdown" class="dropdown-content">
      <a href="https://n2o.dev/ua/deps/kvs/man/kvs.htm">UA</a>
      <a href="#">EN</a>
    </div>
  </div>
</nav><header>
    <a href="../index.html"><img src="https://openmoji.org/data/color/svg/1F4BF.svg"/></a>
    <h1>KVS</h1>
</header>
<main>
  <article>
    <section>

<h3>INTRO</h3>

   <p>KVS module provides user level interface for console commands.
      It has discovery, data manipulation and retrival features. Under the hood
      it handles configurable run-time backends for each supported database.</p>

   <blockquote>
     <ul><li><b><a href="#put">put/1</a></b> — put record using id as a key.</li>
         <li><b><a href="#get">get/2</a></b> — get record by key from table.</li>
         <li><b><a href="#delete">delete/1</a></b> — delete record from table.</li>
         <li><b><a href="#index">index/3</a></b> — search records by field and its value.</li>
         <li><b><a href="#seq">seq/2</a></b> — generate new sequence table id.</li>
         <li><b><a href="#count">count/1</a></b> — counts records in table.</li>
         <li><b><a href="#dir">dir/0</a></b> — table list.</li>
    </ul></blockquote>

 <p>You can change backend by setting application env.
    This behaves well even under the heavy load.</p>

    </section>
    <section>
        <h3>API</h3>
        <p>Data operations.</p>
        <h4 id="put">put(tuple()) -> ok | {error,any()}.</h4>
        <p>Stores the record.</p>
        <h4 id="get">get(atom(),any()) -> {ok,any()} | {error, not_found | duplicated }.</h4>
        <p>Retrieves the record.</p>
        <h4 id="delete">delete(atom(),any()) -> ok | {error,any()}.</h4>
        <p>Deletes the data record.</p>
        <h4 id="index">index(atom(),any(),any()) -> list(tuple()).</h4>
        <p>Searches the record by an indexed field and a given value.</p>
    </section>
    <section>
        <h3>SEQ</h3>
        <p>Sequence table id_seq stores the counter per thing.
           The counters are global and atomic in each supported database.
           Sequences are used to generate unique names for records per distributed table.
           If names in the table are not unique, e.g.
           then count function may return a different value than the current sequence.</p>
        <figure><code> -record(id_seq, { thing = atom(),
                    id    = 0 :: integer() } ).</code></figure>

        <h4 id="seq">seq(atom(), integer()) -> integer().</h4>
        <p>Increments and returns id counter for the particular table.</p>
        <h4 id="count">count(atom()) -> integer().</h4>
        <p>Returns number of records in table.</p>
    </section>
    <section>
        <h3>SETUP</h3>
        <p>In <b>sys.config</b> you can specify main kvs backend module as <b>dba</b> parameter
           and list of modules containing <b>metainfo/0</b> exported function. For the
           stream operations you can specify the stream kvs backend module <b>dba_st</b> parameter.</p>
        <figure><code> [{kvs, [{dba,store_mnesia},
          {dba_st,store_stream},
          {schema,[kvs,kvs_stream]}]}].</code></figure>
        <h4 id="dir">dir() -> list({'table',atom()}).</h4>
        <p>Returns actual tables.</p>
    </section>
    <section>

	<p>This module may refer to:
	<a href="kvs_fs.htm">kvs_fs</a>,
	<a href="kvs_mnesia.htm">kvs_mnesia</a>,
	<a href="kvs_rocks.htm">kvs_rocks</a>,
	<a href="kvs_st.htm">kvs_st</a>,
	<a href="kvs_stream.htm">kvs_stream</a>.
	</p>
    </section>
  </article>
</main>
<footer>2005—2019 © Synrc Research Center</footer>
<script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
</body>
</html>
